import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


public class Leetcode49 {
    public List<List<String>> groupAnagrams(String[] strs) {
       return new ArrayList<>(Arrays.stream(strs).collect(Collectors.groupingBy(str -> {
           char[] chars = str.toCharArray();
           Arrays.sort(chars);
           return new String(chars);
       })).values());
    }
}
